import 'package:flutter/material.dart';
import 'log.dart'; // 添加导入
import 'my.dart'; // 添加导入

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  int _currentIndex = 0;
  final List<Widget> _children = [
    DatabaseScreen(),
    LogsScreen(),
    ProfileScreen(),
  ];

  void onTabTapped(int index) {
    setState(() {
      _currentIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _children[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        onTap: onTabTapped,
        currentIndex: _currentIndex,
        items: [
          BottomNavigationBarItem(
            icon: Icon(Icons.home),
            label: '数据库',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.book),
            label: '日志',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.person),
            label: '我的',
          ),
        ],
      ),
    );
  }
}

class DatabaseScreen extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('数据库'),
        backgroundColor: Colors.purple, // 设置AppBar背景颜色为紫色
        centerTitle: true,
      ),
      body: Center(
        child: Text('数据库'),
      ),
    );
  }
}